package com.zzx.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zzx.common.DataSource;
import com.zzx.common.DataSourcesType;
import com.zzx.common.DynamicDataSourceHolder;
import com.zzx.mapper.RoleMapper;
import com.zzx.mapper.UserMapper;
import com.zzx.model.Role;
import com.zzx.model.User;
import com.zzx.service.IRoleService;
import com.zzx.service.IUserService;

@Service
public class RoleServiceImpl implements IRoleService{

	@Autowired
	private RoleMapper roleMapper;
	
	@DataSource(name=DataSourcesType.DB1)
	@Override
	public void save(Role role) {
		roleMapper.save(role);
		
	}

	@DataSource(name=DataSourcesType.DB1)
	@Override
	public void saveByEntity(Role role) {
		roleMapper.saveByEntity(role);
		
	}
	
	@DataSource(name=DataSourcesType.DB1)
	@Override
	public void update(Role role) {
		roleMapper.update(role);
	}

	@DataSource(name=DataSourcesType.DB1)
	@Override
	public void updateByEntity(Role role) {
		roleMapper.updateByEntity(role);
	}
	
	@DataSource(name=DataSourcesType.DB1)
	@Override
	public void deleteById(String id) {
		roleMapper.deleteById(id);
	}

	@DataSource(name=DataSourcesType.DB1)
	@Override
	public Role getById(String id) {
		System.out.println("**数据源22:"+DynamicDataSourceHolder.getDataSouce());
		return roleMapper.getById(id);
	}

	@DataSource(name=DataSourcesType.DB1)
	@Override
	public List<Role> findAll(Map<String, String> params) {
		
		return roleMapper.findAll(params);
	}

	@DataSource(name=DataSourcesType.DB1)
	@Override
	public int getCount(Map<String, String> params) {
		
		return roleMapper.getCount(params);
	}

}
